IndexApi
A class for interfacing with the Vecto Index API.
Methods:
indexData
async indexData(requestParameters: IndexDataRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<IndexResponse>
Create an entry in the index for Image or Text data and store them in the provided vector space.
Args:
- requestParameters (IndexDataRequest): Parameters for the index data request.
vectorSpaceId
: The ID of the vector space to index in (required).modality
: The modality of the data.attributes
: Array of attributes.input
: Array of input data.
- initOverrides (RequestInit or runtime.InitOverrideFunction): Overrides for the request initialization.
Returns:
- IndexResponse: Response of the index data operation.
status
: Status of the index operationids
: Array containing the unique IDs of the indexed data items.
- Text
- Image
import { Configuration, IndexApi, IndexDataRequest, Modality } from 'vecto-sdk'
const config = new Configuration({
accessToken: 'your-token'
});
const api = new IndexApi(config);
const textDataParams: IndexDataRequest = {
vectorSpaceId: 'your-vector-space-id',
modality: 'TEXT',
attributes: [JSON.stringify('sample metadata')],
input: [new Blob(['sample data to vectorize and ingest'])],
};
const responseText = await api.indexData(textDataParams);
import { Configuration, IndexApi, IndexDataRequest, Modality } from 'vecto-sdk'
import fs from 'fs';
const config = new Configuration({
accessToken: 'your-token'
});
const api = new IndexApi(config);
const fileContent = fs.readFileSync('path/to/your/image.png');
const imageBlob = new Blob([fileContent]);
const imageDataParams: IndexDataRequest = {
vectorSpaceId: 'your-vector-space-id',
modality: 'IMAGE',
attributes: [JSON.stringify('sample metadata')],
input: [imageBlob],
};
const responseImage = await api.indexData(imageDataParams);